/*
    kOTF Open Trace Format - a library for generating execution traces.
    Copyright 2012 Daniel K. O.

    kOTF is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    kOTF is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with kOTF.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef KOTF_ERROR_H
#define KOTF_ERROR_H

#include <kotf/Types.hpp>

namespace kotf {
    /** \brief Base class for kOTF exceptions

        Use the what() member function for a textual description of the error.
     */
    class Error  {
        string msg;
    protected:
        Error(const string& m);
    public:
        const string& what() const throw(); ///< returns the error message
    };


    struct InvalidIdError : Error {
    protected:
        InvalidIdError(const string& w, uint64_t id);
    }; ///< Base error class for invalid id exceptions

    struct InvalidStateId : InvalidIdError {
        InvalidStateId(uint64_t id);
    };   ///< No state exists with this id

    struct InvalidCounterId : InvalidIdError {
        InvalidCounterId(uint64_t id);
    }; ///< No counter exists with this id

    struct InvalidChannelId : InvalidIdError {
        InvalidChannelId(uint64_t id);
    }; ///< No channel exists with this id



    // Errors from the reading interface
    /// \brief session file seems to be invalid
    struct InvalidSession : Error {
        InvalidSession(const string& m);
    };
    /// \brief record description is unknown
    struct UnknownRecord : InvalidSession {
        UnknownRecord(const string& m);
    };

    struct OpenError : Error {
        OpenError(const string& m);
    };
    struct MmapError : Error {
        MmapError(const string& m);
    };

    struct InvalidStream : Error {
        InvalidStream(const string&);
    };

};


#endif
